package com.tancire.system.service.impl;

import java.util.List;
import javax.annotation.Resource;
import com.tancire.common.utils.DateUtils;
import com.tancire.system.domain.SysVisitCount;
import org.springframework.stereotype.Service;
import com.tancire.system.mapper.SysAppLogMapper;
import com.tancire.system.domain.SysAppLog;
import com.tancire.system.service.ISysAppLogService;

/**
 * 应用日志Service业务层处理
 *
 * @author tancire
 * @date 2024-06-13
 */
@Service
public class SysAppLogServiceImpl implements ISysAppLogService {
    @Resource
    private SysAppLogMapper sysAppLogMapper;

    /**
     * 查询应用日志
     *
     * @param id 应用日志主键
     * @return 应用日志
     */
    @Override
    public SysAppLog selectSysAppLogById(Long id) {
        return sysAppLogMapper.selectSysAppLogById(id);
    }

    /**
     * 查询应用日志列表
     *
     * @param sysAppLog 应用日志
     * @return 应用日志
     */
    @Override
    public List<SysAppLog> selectSysAppLogList(SysAppLog sysAppLog) {
        return sysAppLogMapper.selectSysAppLogList(sysAppLog);
    }

    /**
     * 新增应用日志
     *
     * @param sysAppLog 应用日志
     * @return 结果
     */
    @Override
    public int insertSysAppLog(SysAppLog sysAppLog) {
        sysAppLog.setCreateTime(DateUtils.getNowDate());
        return sysAppLogMapper.insertSysAppLog(sysAppLog);
    }

    /**
     * 修改应用日志
     *
     * @param sysAppLog 应用日志
     * @return 结果
     */
    @Override
    public int updateSysAppLog(SysAppLog sysAppLog) {
        sysAppLog.setUpdateTime(DateUtils.getNowDate());
        return sysAppLogMapper.updateSysAppLog(sysAppLog);
    }

    /**
     * 批量删除应用日志
     *
     * @param ids 需要删除的应用日志主键
     * @return 结果
     */
    @Override
    public int deleteSysAppLogByIds(Long[] ids) {
        return sysAppLogMapper.deleteSysAppLogByIds(ids);
    }

    /**
     * 删除应用日志信息
     *
     * @param id 应用日志主键
     * @return 结果
     */
    @Override
    public int deleteSysAppLogById(Long id) {
        return sysAppLogMapper.deleteSysAppLogById(id);
    }

    /**
     * 查询昨日访问量汇总
     *
     * @param appId
     * @return
     */
    @Override
    public List<SysVisitCount> selectYdVisitCount(Long appId) {
        return sysAppLogMapper.selectYdVisitCount(appId);
    }

    /**
     * 删除昨日日志
     */
    @Override
    public void deleteYdLog() {
        sysAppLogMapper.deleteYdLog();
    }
}
